package com.lql.lqlreader

import android.animation.Animator
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import com.jaeger.library.StatusBarUtil
import kotlinx.android.synthetic.main.activity_login_animation.*

class LaunchingActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_login_animation)
        supportActionBar?.hide()

        // 调用第三方库statusbar，将状态栏设为透明
        // 详见https://github.com/laobie/StatusBarUtil
        StatusBarUtil.setTransparent(this)
        //lottie，第三方的动画制作库，详见 https://github.com/airbnb/lottie-android
        ltv_loginAnimationView.playAnimation()
        ltv_loginAnimationView.speed = 1.5F

        ltv_loginAnimationView.addAnimatorListener(object : Animator.AnimatorListener {
            override fun onAnimationCancel(animation: Animator?) {  }

            override fun onAnimationRepeat(animation: Animator?) {  }

            override fun onAnimationStart(animation: Animator?) {
                LQlReaderApplication.showLogoInLog()
            }

            override fun onAnimationEnd(animation: Animator?) {
                tv_appname.visibility = View.VISIBLE
                startActivity(Intent(this@LaunchingActivity, MainActivity::class.java))
                finish()
            }
        })
    }
}